package com.itheima.controller;

import com.itheima.config.Student;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;
import java.util.List;

@RestController
public class HelloController {

    @Autowired
    private DataSource dataSource;

    @Value("${city[0]}")
    private String city;

    /*@Autowired
    private List student;*/

    @Autowired
    private UserService userService;

    @GetMapping("/user/{id}")
    public User findAll(@PathVariable Long id){
        return userService.findAll(id);
    }

    @RequestMapping("/hello")
    public String hello(){
        System.out.println("dataSource = " + dataSource);
        System.out.println("city = " + city);
        /* for (Object o : student) {
            System.out.println("student = " + o);
        }*/

        return "Hello,Spring Boot!";
    }
}
